/*
 * ColumnCellEditorPropertiesDisponibleColumnValue.java
 * Copyright 2010 Universidad Francisco de Paula Santander (UFPS).
 * Todos los Derechos Reservados.
 * Creado el 18/04/2010, 11:31:30 PM
 */


package com.ufps.cuatro.util.editor;

import java.awt.Component;

import javax.swing.AbstractCellEditor;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.table.TableCellEditor;

import com.ufps.cuatro.util.opciones.TypeOptionPreferences;

/**
 * <i><b>ColumnCellEditorPropertiesDisponibleColumnValue:</b></i> @DescripcionClase
 * @author Carlos A. Torres C. - Dolly E. Guerrero. <https://code.google.com/p/tesis4dor/>
 * @version 1.0 18/04/2010
 * @see AbstractCellEditor
 * @see TableCellEditor
 */
public class ColumnCellEditorPreferencesColumnValues extends AbstractCellEditor implements TableCellEditor{
    private static final long serialVersionUID = 5517167209392663961L;

    private Object obj;
    
    /**
     * @DescripcionMetodo
     */
    public ColumnCellEditorPreferencesColumnValues() {    
    }

    public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {        
                
        if(column == 1 && value instanceof TypeOptionPreferences){
            this.obj = value;
            TypeOptionPreferences objTempValue = (TypeOptionPreferences) value;
            switch(objTempValue.getType()){
                case TypeOptionPreferences.TYPE_BOOLEAN:
                    return new CheckBoxTableProperties(objTempValue, Boolean.valueOf(objTempValue.getValue()));
                default:
                    JLabel objLbl = new JLabel(objTempValue.getValue());                    
                    return objLbl;
            }
        }
        return new JLabel("");
    }

    public Object getCellEditorValue() {
        return this.obj;
    }
}

